package org.wxd.bi.api.struct;

import org.wxd.lang.save.ObjectBase;
import org.wxd.timer.TimeUtil;

import java.io.Serializable;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
import java.util.TreeMap;

/**
 * 留存数据
 *
 * @author: Troy.Chen(無心道, 15388152619)
 * @version: 2021-10-15 10:38
 **/
public class CountData extends ObjectBase implements Serializable {

    private static final long serialVersionUID = 1L;

    private Set<Long> loginSet = new HashSet<>();

    private Map<String, Set<Long>> rr = new TreeMap<>();

    public CountData() {
    }

    public void addLogin(long loginId) {
        loginSet.add(loginId);
    }

    public void addRR(long loginId, long createTime, long loginTime) {
        int dayOffset = TimeUtil.getDayCount(createTime, loginTime) + 1;
        String s = "r" + dayOffset;
        Set<Long> longs = rr.computeIfAbsent(s, l -> new HashSet<>());
        longs.add(loginId);
    }

    public Set<Long> getLoginSet() {
        return loginSet;
    }

    public CountData setLoginSet(Set<Long> loginSet) {
        this.loginSet = loginSet;
        return this;
    }

    public Map<String, Set<Long>> getRr() {
        return rr;
    }

    public CountData setRr(Map<String, Set<Long>> rr) {
        this.rr = rr;
        return this;
    }
}
